<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>地址管理</title>
    <style type="text/css">
        html{height:100%}
        body{height:100%;margin:0px;padding:0px}
        #container{height:100%}
    </style>
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=3V1b9H41F7LOqEyF4hcFyVaWjqGwnwFS">
    </script>
</head>

<body>
<div id="container"></div>
<script src="../js/axios-0.18.0.js"></script>
<script type="text/javascript">

    // let mapDetails=[];

    window.onload=function () {
        /*let address  = [
            {longitude:114.3105,latitude:30.5962},
            {longitude:114.3133,latitude:30.5894},
            {longitude:114.3002,latitude:30.5888}
        ];

        var map = new BMapGL.Map("container");
        map.centerAndZoom(new BMapGL.Point(114.3105, 30.5962), 15);
        map.enableScrollWheelZoom(true);

        for (let i = 0; i <address.length ; i++) {
            var marker = new BMapGL.Marker(new BMapGL.Point(address[i].longitude, address[i].latitude));
            map.addOverlay(marker);
        }*/


        let url = "/address/getMap";
        axios.get(url).then(response => {
            if (response.data.flag){
                /*[
                    {longitude:114.3105,latitude:30.5962},
                    {longitude:114.3133,latitude:30.5894},
                    {longitude:114.3002,latitude:30.5888}
                ]*/

                let address  = response.data.data;

                var map = new BMapGL.Map("container");
                map.centerAndZoom(new BMapGL.Point(114.3105, 30.5962), 15);
                map.enableScrollWheelZoom(true);

                for (let i = 0; i <address.length ; i++) {
                    // alert(address);
                    var marker = new BMapGL.Marker(new BMapGL.Point(address[i].longitude, address[i].latitude));
                    map.addOverlay(marker);
                }

            }else {
                this.$message.error(response.data.message);
            }
        });
    };
</script>
</body>
</html>